<template>
  <el-container>
    <el-header>
      <el-row>
        <el-col :span="2">
          <div @click="gb()"> 
            <i v-if="iscollapse==false" class="el-icon-s-fold"></i>
            <i v-else class="el-icon-s-unfold"></i>
          </div>
        </el-col>
        <el-col :span="4"> 物信管理系统 </el-col>
      </el-row>
    </el-header>
    <el-container>
      <el-aside :width="iscollapse ? '64px' : '200px'">
        <!--菜单栏区-->
        <el-menu
          default-active="2"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          :unique-opened="true"
          :router="true"
          :collapse="iscollapse"
          :collapse-transition=false
        >
          <!--1级菜单-->
          <el-submenu :index="item.id + ''" v-for="item in list" :key="item.id">
            <!--1级菜单模版区-->
            <template slot="title">
              <!--1级菜单模版区图标-->
              <i :class="iconobj[item.id]"></i>
              <!--1级菜单模版区文字-->
              <span>{{ item.authName }}</span>
            </template>
            <!--2级菜单-->
            <el-menu-item
              :index="item1.path"
              v-for="item1 in item.children"
              :key="item1.id"
            >
              <template slot="title">
                <!--2级菜单模版区图标-->
                <i class="el-icon-menu"></i>
                <!--2级菜单模版区文字-->
                <span slot="title">{{ item1.authName }}</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
      //左侧导航数据
      list: [
        {
          id: 1,
          authName: "系统管理",
          path: null,
          children: [
            {
              id: 104,
              authName: "用户列表",
              path: "/user",
              children: [],
            },
          ],
        },
        {
          id: 2,
          authName: "商品管理",
          path: null,
          children: [
            {
              id: 204,
              authName: "商品列表",
              path: "/product",
              children: [],
            },
          ],
        },
      ],
      //根据id值来关联图标
      iconobj: {
        1: "el-icon-s-tools",
        2: "el-icon-s-goods",
      },
      //控制左侧导航栏是否折叠
      iscollapse: false,
    };
  },
  methods:{
      gb(){
          this.iscollapse=!this.iscollapse;
      }
  }
};
</script>
<style scoped>
.el-header {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}
.el-container {
  height: 550px;
}
.el-menu {
  border-right: 0px;
  height: 100%;
}
</style>